#include <glf.h>
#include <glfwindow.h>

#include <stdio.h>

static void initialise(void* userdata)
{
	int numExtensions = 0;
	int i = 0;
	glGetIntegerv( GL_NUM_EXTENSIONS, &numExtensions );
	for( i = 0; i < numExtensions; ++i )
	{
		printf( "GL_EXTENSIONS(%u): %s\n", i, glGetStringi( GL_EXTENSIONS, i ) );
	}
}

static void think(void* userdata)
{
}

static void render(void* userdata)
{
    /* swapping buffers is done by the mainloop implicitly */
    glClear(GL_COLOR_BUFFER_BIT);
}

static void resize(void* userdata)
{
   glViewport(0,0,glfGetWidth(),glfGetHeight());
}

int main(void)
{
    int hasinit = 0;

    glfConfigSetAttribute(glfMajorVersion, 3);
    glfConfigSetAttribute(glfMinorVersion, 1);
    glfConfigSetAttribute(glfContextFlags, glfContextForwardCompatible);
    
    if( !glfCreateWindow( "Extensions", 640, 480 ) )
        return -1;

	glfSetCallBack(glfCallbackInitialise, initialise, NULL );
    glfSetCallBack(glfCallbackThink, think, &hasinit);
    glfSetCallBack(glfCallbackRender, render, NULL);
    glfSetCallBack(glfCallbackResize, resize, NULL);
    
    if( !glfMainloop() )
        return -1;

    glfDestroyWindow();
    return 0;
}
